<%--
  Created by IntelliJ IDEA.
  User: wolfleong
  Date: 2018/4/16
  Time: 下午11:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/bootstrap.min.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="${pageContext.request.contextPath}/static/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="${pageContext.request.contextPath}/static/bootstrap.min.js"></script>
    <script type="text/javascript" src="http://common.cnblogs.com/script/jquery.js"></script>
    <script>
        var xmlhttp;
        if (window.XMLHttpRequest) {
            xmlhttp = new XMLHttpRequest(); // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        }
        else {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // IE6, IE5 浏览器执行代码
        }

        function userInfo(userId) {
            xmlhttp.open("GET", "/user/getUser?userId="+userId+"&update=false", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            xmlhttp.send();
        }

        function newsInfo() {
            xmlhttp.open("GET", "/newsInfo/getAllNewsInfo?currentPage=1&pageSize=5", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            xmlhttp.send();
        }

        function userAdmin() {
            xmlhttp.open("GET", "/user/getLimitUser?currentPage=1&pageSize=5", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            xmlhttp.send();
        }

        function commentAdmin() {
            xmlhttp.open("GET", "/comment/getAllComment?currentPage=1&pageSize=5", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            xmlhttp.send();
        }
        //todo
        function homePageAdmin() {
            window.open("${pageContext.request.contextPath}/view/homePage.jsp")
            // xmlhttp.open("GET", "/comment/getAllNewsInfo?currentPage=1&pageSize=5", true);
            // xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            // xmlhttp.send();
        }
        function category() {
            xmlhttp.open("POST", "/category/list", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            xmlhttp.send();
        }
        function picture() {
            xmlhttp.open("GET", "/comment/getAllNewsInfo?currentPage=1&pageSize=5", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;");
            xmlhttp.send();
        }

    </script>
</head>
<style>
    .navbar-collapse {
        padding-left: 5px;
        padding-right: 5px;
    }

    .nav > li {
        text-align: center;
    }

    .nav > li > a {
        color: #444;
        margin: 0 5px;
    }

    .nav-pills > li.active > a, .nav-pills > li.active > a:focus, .nav-pills > li.active > a:hover {
        background-color: #222222;
    }

    .dropdown-menu {
        min-width: 200px;
        margin-left: 40px;
        background-color: #E3E3E3;
    }

    .dropdown-menu > li > a {
        padding: 10px 15px;
    }

    body {
        width: 100%;
        height: 100%;
        margin: 0;
        overflow: hidden;
        background-color: #FFFFFF;
        font-family: "Microsoft YaHei", sans-serif;
    }

    .pageSidebar {
        width: 240px;
        height: 100%;
        padding-bottom: 30px;
        overflow: auto;
        background-color: #e3e3e3;
    }

    .splitter {
        width: 5px;
        height: 100%;
        bottom: 0;
        left: 240px;
        position: absolute;
        overflow: hidden;
        background-color: #fff;
    }

    .pageContent {
        height: 100%;
        min-width: 768px;
        left: 246px;
        top: 0;
        right: 0;
        z-index: 3;
        padding-bottom: 30px;
        position: absolute;
    }

    .pageContainer {
        bottom: 0;
        left: 0;
        right: 0;
        top: 53px;
        overflow: auto;
        position: absolute;
        width: 100%;
    }

    .footer {
        width: 100%;
        height: 30px;
        line-height: 30px;
        margin-top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        position: absolute;
        z-index: 10;
        background-color: #DFDFDF;
    }

</style>
<body>
<!--顶部导航栏部分-->
<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" title="logoTitle" href="#">简易新闻管理后台</a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li role="presentation">
                    <a href="#">当前用户：<span class="badge">${user.name}</span></a>
                </li>
                <li>
                    <a href="/user/logout">
                        <span class="glyphicon glyphicon-lock"></span>退出登录
                    </a>
                </li>
                <li>
                    <a href="/newsInfo/allNewsInfo">
                        <span class="glyphicon glyphicon-lock"></span>首页
                    </a>
                </li>
            </ul>
        </div>
    </div>
</nav>
<!-- 中间主体内容部分 -->
<div class="pageContainer">
    <!-- 左侧导航栏 -->
    <div class="pageSidebar">
        <ul class="nav nav-stacked nav-pills">
            <li role="presentation">
                <a href="${pageContext.request.contextPath}/view/categoryManage.jsp" target="mainFrame" onclick="category()">分类管理</a>
            </li>
            <li role="presentation">
                <a href="${pageContext.request.contextPath}/newsInfo/getAllNewsInfo?currentPage=1&pageSize=10" target="mainFrame" onclick="newsInfo()">新闻管理</a>
            </li>
            <%--<li role="presentation">--%>
                <%--<a href="${pageContext.request.contextPath}/view/pictureManage.jsp" target="mainFrame" onclick="picture()">热图管理</a>--%>
            <%--</li>--%>
            <li role="presentation">
                <a href="${pageContext.request.contextPath}/view/userInfo.jsp" target="mainFrame" onclick="userInfo(${user.userId})">我的信息</a>
            </li>
            <li role="presentation">
                <a href="${pageContext.request.contextPath}/user/getLimitUser?currentPage=1&pageSize=10" target="mainFrame" onclick="userAdmin()">用户管理</a>
            </li>
            <li role="presentation">
                <a href="${pageContext.request.contextPath}/comment/getAllComment?currentPage=1&pageSize=10" target="mainFrame" onclick="commentAdmin()">评论管理</a>
            </li>
            <li role="presentation">
                <a target="mainFrame" onclick="homePageAdmin()">打开首页</a>
                <%--<a href="${pageContext.request.contextPath}/view/homePage.jsp" target="mainFrame" onclick="homePageAdmin()">打开首页</a>--%>
            </li>
            <%--<li class="dropdown">--%>
                <%--<a class="dropdown-toggle" data-toggle="dropdown" href="#">--%>
                    <%--导航链接4<span class="caret"></span>--%>
                <%--</a>--%>
                <%--<ul class="dropdown-menu">--%>
                    <%--<li>--%>
                        <%--<a href="nav1.html" target="mainFrame">导航链接4-1</a>--%>
                    <%--</li>--%>
                    <%--<li>--%>
                        <%--<a href="nav2.html" target="mainFrame">导航链接4-2</a>--%>
                    <%--</li>--%>
                    <%--<li>--%>
                        <%--<a href="nav3.html" target="mainFrame">导航链接4-3</a>--%>
                    <%--</li>--%>
                <%--</ul>--%>
            <%--</li>--%>
            <%--<li role="presentation">--%>
                <%--<a href="nav4.html" target="mainFrame">导航链接5</a>--%>
            <%--</li>--%>
        </ul>
    </div>
    <!-- 左侧导航和正文内容的分隔线 -->
    <div class="splitter"></div>
    <!-- 正文内容部分 -->
    <div class="pageContent">
        <iframe src="${pageContext.request.contextPath}/view/index.jsp" id="mainFrame" name="mainFrame" frameborder="0" width="100%" height="100%"
                frameBorder="0"></iframe>
    </div>
</div>
<!-- 底部页脚部分 -->
<div class="footer">
    <p class="text-center">
        2017 &copy; NeoYang.
    </p>
</div>

</body>
</html>
<script>
    $(".nav li").click(function () {
        $(".active").removeClass('active');
        $(this).addClass("active");
    });
</script>
